package com.shuhua.taskServer.controller;

import com.shuhua.pojo.entity.TaskHandleResource;
import com.shuhua.taskServer.service.TaskHandleResourceService;
import com.shuhua.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/taskHandleResource")
public class TaskHandleResourceController {
    @Autowired
    private TaskHandleResourceService taskHandleResourceService;

    @PostMapping
    public Result<?> add(@RequestBody TaskHandleResource resource) {
        taskHandleResourceService.save(resource);
        return Result.success();
    }

    @DeleteMapping("/{resourcesId}")
    public Result<?> delete(@PathVariable Long resourcesId) {
        taskHandleResourceService.removeById(resourcesId);
        return Result.success();
    }

    @PutMapping
    public Result<?> update(@RequestBody TaskHandleResource resource) {
        taskHandleResourceService.updateById(resource);
        return Result.success();
    }

    @GetMapping("/{resourcesId}")
    public Result<TaskHandleResource> get(@PathVariable Long resourcesId) {
        TaskHandleResource resource = taskHandleResourceService.getById(resourcesId);
        return Result.success(resource);
    }

    @GetMapping("/list")
    public Result<List<TaskHandleResource>> list() {
        List<TaskHandleResource> list = taskHandleResourceService.list();
        return Result.success(list);
    }
} 